﻿
using System;
using DG.Tweening;
using FixMath.NET;
using GameConfig.slot;
using GameProtocol;
using Google.Protobuf;
using TEngine;
using TMPro;
using UnityEngine;

namespace GameLogic
{
    partial class FloatingTips
    {
        #region 生命周期回调
        protected override void OnCreate()
        {
            base.OnCreate();
        }

        protected override void OnUpdate()
        {
            base.OnUpdate(); 
        }

        protected override void OnRefresh()
        {
            base.OnRefresh();
            var tipStr = GetUserData<string>(0);

            try
            {
                var tip = PoolManager.Instance.GetGameObject("Assets/AssetRaw/UI/FloatingTips/FloatingTip.prefab", transform);
                var txt = tip.transform.FindChildComponent<TextMeshProUGUI>("Root/Text");
                txt.text = tipStr;
                DOVirtual.DelayedCall(1, () =>
                {
                    PoolManager.Instance.PushGameObject(tip.gameObject);
                });
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
        #endregion

    }
}